using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

using Microsoft.Ink;

namespace SpellingQuiz
{
    public partial class InkPanel : UserControl
    {
        // Declare the Ink Collector object
        private InkCollector myInkCollector;

        // myRecognizers is used to retrieve the number of installed recognizers
        static Recognizers myRecognizers = new Recognizers();

        public InkPanel()
        {
            InitializeComponent();
        }

        static public bool InkAvailable
        {
            get { return myRecognizers.Count > 0; }
        }

        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        [Description("The caption shown above the ink area")]
        public override string Text
        {
            get { return inkGroupBox.Text; }
            set { inkGroupBox.Text = value; }
        }

        [Browsable(true)]
        [ReadOnlyAttribute(true)]
        public string RecoString
        {
            get { return myInkCollector.Ink.Strokes.ToString(); }
        }

        public void ClearInk()
        {
            // If the mouse is pressed, do not perform the deletion - 
            // this prevents deleting a stroke that is still being drawn
            if (!myInkCollector.CollectingInk)
            {
                // Once the strokes have been recognized, delete them
                myInkCollector.Ink.DeleteStrokes();

                // Repaint the drawing area
                inkGroupBox.Refresh();
            }
        }

        private void InkPanel_Load(object sender, EventArgs e)
        {
            // Create a new ink collector that uses the group box handle
            myInkCollector = new InkCollector(inkGroupBox.Handle);

            // Turn the ink collector on
            myInkCollector.Enabled = true;          

        }
	
    }
}
